<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="fck" uri="http://java.fckeditor.net" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="<%=request.getContextPath()%>/common/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/common/FSS.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/jquery-1.3.min.js"></script>


<script type="text/javascript">

function fnDelete(){
	if(confirm("削除しますか？")){
		document.deleteForm.submit();
	}
}

function fnEdit(){
	document.initEditForm.submit();
}

//add comment
function fnComment(){
	//$("#comment_submit").attr("disabled","disabled");
	var name = $("#g_name").val();
	if(name==""){
		alert("ログインしてください！");
		$("#comment").focus();
		return false;
	}
	
	var experienceId = $("#ex_id").val();

	var date = new Date();
	var datestr=date.pattern("yyyy-MM-dd hh:mm:ss"); 
	
    var comment = $("#comment").val();
    
    var strUrl = "<s:url action="addComment" namespace="/experience"></s:url>";
	var querystr = "comment.content="+encodeURIComponent(comment)
	                    +"&experience.experienceId="+encodeURIComponent(experienceId);
	  $.post(strUrl, querystr, function(objRet){

	        if(objRet.status == "success") {
	        	alert("コメント登録成功！");
	        	var content = '<ul class="articles"><div class="block"><h4>' + name +'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ datestr +'</h4><h4>' + comment + '</h4></div></ul>';
	            
	            $("#ooxx").html(content + $("#ooxx").html());
	            $("html,body").animate({scrollTop: $("#ooxx").offset().top - 30}, "normal");
	            $("#comment").val("");
	
	        }else{
	        	alert("コメント登録失敗！\r\n\r\nエラー：" + objRet.message);
	
	            }
	
	        },"json");
	
}

function fnAddContect(userId){
	var strUrl = "<s:url action="addContect" namespace="/experience"></s:url>";
	var querystr = "contectUserId="+encodeURIComponent(userId);
	  $.post(strUrl, querystr, function(objRet){

	        if(objRet.status == "success") {
	        	alert("連絡先追加完了！");
	
	        }else{
	        	alert("絡先追加失敗！\r\n\r\nエラー：" + objRet.message);
	
	            }
	
	        },"json");
	
}
</script>
</head>
<body id="page4">
<div class="tail-right"></div>
<div class="tail-right-top"></div>
<div class="tail-top">
  <div class="tail-bottom">
    <div class="tail-bg">
      <div class="top-bg">
        <div class="tail-right-bot"></div>
        <div class="bot-bg">
          <div id="main">
            <!-- header -->
            <s:form name="login" action="/fssProject/Login" theme="simple">
            <div id="header">
              <h1><a href="<%=request.getContextPath()%>">fss</a></h1>
              <ul class="top-login">
              <s:if test="#session.user_login==null">
                <li><img alt="" src="../images/userid.gif" /></li>
                <li><input type="text" name="user.userId" id="user_name" /></li>
                <li><img alt="" src="../images/password.gif" /></li>
                <li><input type="password" name="user.pwd" id="password" /></li>
                <li><a class="loginbutton" href="javascript:fnLogin();"></a></li>
                <li><a class="registerbutton" href="/fssProject/user/initRegister" ></a></li>
              </s:if><s:else>
              	<li><h4><s:property value="#session.user_login.displayName"/>,Welcome!</h4></li>
              	<li><a class="mypagebutton" href="/fssProject/user/myInfo"></a></li>
                <li><a class="logoutbutton" href="/fssProject/Logout"></a></li>
                </s:else>
              </ul>
            </div>
            </s:form>
            <div class="extra-img"><img alt="" src="../images/extra-img.png" class="png"/></div>
            <div class="wrapper">
              <!-- nav -->
              <div id="nav">
                <ul>
                 <li><a href="/fssProject/mainPage">ホーム</a></li>
                  <li><a href="/fssProject/experience/list"><s:property value="#session.btn1.content"/></a></li>
                  <li><a href="/fssProject/secondHand/list"><s:property value="#session.btn2.content"/></a></li>
                  <s:if test="#session.user_login.userId in {'fss_admin1','fss_admin2','fss_admin3'}">
                  <li><a href="/fssProject/user/userManage">ユーザ管理</a></li>
                  <li><a href="/fssProject/cmsContent/editCMSContent">CMS変更</a></li>
                  </s:if>
                </ul>
              </div>
              <!-- content -->
              <div id="content">
              <s:hidden id="g_name" name="#session.user_login.displayName"/>
              <s:hidden id="ex_id" name="experience.experienceId"/>
                <div class="section">
                  <!-- box begin -->
                  <div class="box">
                    <div class="left-top-corner png">
                      <div class="right-top-corner png">
                        <div class="border-top png"></div>
                      </div>
                    </div>
                    <div class="border-left png">
                      <div class="border-right png">
                        <div class="inside png">
                        	<ul class="articles">
                        	<div class="blockm">
                              <h3><s:property value="experience.title"/>
                              <s:if test="experience.tbUser.userId ==#session.user_login.userId ">
                              	<a class="deleteMessage" href="javascript:fnDelete();"></a>
                              	<a class="hennkou" href="javascript:fnEdit();"></a> 
                              </s:if><s:elseif test="#session.user_login.userId in {'fss_admin1','fss_admin2','fss_admin3'}">
                              	<a class="deleteMessage" href="javascript:fnDelete();"></a>
                              </s:elseif><s:else></s:else>
                              </h3>
                              
                              <div  class="panel">
                              <s:if test="experience.tbUser.userId ==#session.user_login.userId ">
                              <a href="#"><h4>作成者：<s:property value="experience.tbUser.displayName"/></h4>
                              </s:if><s:else>
								<a href="javascript:fnAddContect('<s:property value='experience.tbUser.userId'/>');"><h4>作成者：<s:property value="experience.tbUser.displayName"/></h4>
								</s:else>
								<div>

									<h4>所属:<s:property value="experience.tbUser.workingPlace"/></h4>
									<h4>Eメール:<s:property value="experience.tbUser.email"/> </h4>
	
								</div></a>
							  </div>
                              
                              
                              
                              <h4>種類：<s:property value="experience.tbExperienceType.typeName"/> </h4>
                              <h4>投稿時間：<s:date name="experience.createdTime" format="yyyy-MM-dd"/> </h4>
                              
                            
                              <div id="d_content" class="field">
                              
                                <s:property value="experience.content" escape="false"/>
                              </div>
                              </div> 
                            </ul> 
                              <div id="ooxx" class="commit">
                              <ul class="articles">
                             	 <s:iterator id="comment" status="or" value="commentList">
                          			
                           			 <div class="block">
                              		<h4><s:property value="#comment.generatorName"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<s:date name="#comment.createdTime"/></h4>
                              			
                              			<h4><s:property value="#comment.content" /></h4>
                              		 </div>
                             	 </s:iterator>
                              </ul>
                              </div>
                              <form id="contact-form" action="#">
                            		<fieldset>
                                		<s:textarea id="comment" name="comment.content"/>
                            		</fieldset>
                            	</form>
                              <a class="activeNew"  href="javascript:fnComment();"></a>
                         </div>
                      </div>
                    </div>
                    <div class="left-bot-corner png">
                      <div class="right-bot-corner png">
                        <div class="border-bot png"></div>
                      </div>
                    </div>
                  </div>
                  <!-- box end -->
                </div>
              </div>
            </div>
          </div>
          <!-- footer -->
          <div id="footer">
            <div class="indent">
              <div class="fleft">Copyrights - Ritsumeikan University</div>
              <div class="fright">Designed by: <a href="http://www.ritsumei.jp/ise/index_j.html"><img src="../images/designer.gif" /> </a>Provider</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<s:form name="deleteForm" action="del" theme="simple"> 
     <s:hidden name="experience.experienceId"/>
</s:form>
<s:form name="initEditForm" action="initEdit" theme="simple"> 
     <s:hidden name="experience.experienceId"/>
</s:form>
</body>
</html>